package contest1609;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class DBraceMatcher {
    static Scanner cin = new Scanner(new BufferedInputStream(System.in));//大量输入优化版本
    static PrintWriter cout = new PrintWriter(new BufferedOutputStream(System.out));//大量输出优化版本
    static PrintWriter cerr = new PrintWriter(System.err, true);//开启调试模式,一般输出量不大，不需要buffered

    static boolean check(String exp) {
        char[] S = new char[exp.length() + 1];
        int top = -1;
        for (char ch : exp.toCharArray()) {
            if ("([{".indexOf(ch) >= 0) {
                S[++top] = ch;
            } else if (ch == ')') {
                if (top == -1 || S[top] != '(') return false;
                --top;
            } else if (ch == ']') {
                if (top == -1 || S[top] != '[') return false;
                --top;
            } else if (ch == '}') {
                if (top == -1 || S[top] != '{') return false;
                --top;
            }
        }
        return top == -1;
    }

    public static void main(String[] args) {
        //TODO AOJ开启你的ACM传奇人生
        cerr.println("----Start your ACM legendary life with AOJ(www.webturing.com)----");


        while (cin.hasNext()) {
            if (check(cin.next())) {
                cout.println("YES");
            } else {
                cout.println("NO");
            }
        }


        cin.close();//关闭输入流
        cout.close();//关闭输出流，这是必须的，否则一般不会自动刷新缓冲区
    }
}
